namespace WpfClient.Core.Models
{
    /// <summary>
    /// 客户端信息
    /// </summary>
    public class ClientInfo
    {
        public string Id { get; set; } = string.Empty;
        public string IpAddress { get; set; } = string.Empty;
        public int Port { get; set; }
        public DateTime ConnectedAt { get; set; }
        public bool IsConnected { get; set; }
        public long BytesSent { get; set; }
        public long BytesReceived { get; set; }
        public DateTime LastActivity { get; set; }
    }

    /// <summary>
    /// 客户端连接事件参数
    /// </summary>
    public class ClientConnectedEventArgs : EventArgs
    {
        public ClientInfo Client { get; }

        public ClientConnectedEventArgs(ClientInfo client)
        {
            Client = client;
        }
    }

    /// <summary>
    /// 客户端断开连接事件参数
    /// </summary>
    public class ClientDisconnectedEventArgs : EventArgs
    {
        public ClientInfo Client { get; }
        public string Reason { get; }

        public ClientDisconnectedEventArgs(ClientInfo client, string reason)
        {
            Client = client;
            Reason = reason;
        }
    }

    /// <summary>
    /// 数据发送事件参数
    /// </summary>
    public class DataSentEventArgs : EventArgs
    {
        public string ClientId { get; }
        public byte[] Data { get; }
        public bool Success { get; }
        public string? ErrorMessage { get; }

        public DataSentEventArgs(string clientId, byte[] data, bool success, string? errorMessage = null)
        {
            ClientId = clientId;
            Data = data;
            Success = success;
            ErrorMessage = errorMessage;
        }
    }

    /// <summary>
    /// 数据接收事件参数
    /// </summary>
    public class DataReceivedEventArgs : EventArgs
    {
        public string ClientId { get; }
        public byte[] Data { get; }

        public DataReceivedEventArgs(string clientId, byte[] data)
        {
            ClientId = clientId;
            Data = data;
        }
    }
}